package com.istock.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import com.istock.base.common.api.model.ApiBaseResponse;
import com.istock.base.common.api.model.PageInfo;
import com.istock.base.common.api.model.RetStatusEnum;
import com.istock.union.user.model.Constants;
import com.istock.union.user.model.LoginLogQuery;
import com.istock.union.user.model.LoginforInfo;
import com.istock.union.user.model.OperLog;
import com.istock.union.user.model.SecurityChecker;
import com.istock.union.user.service.LoginforInfoService;

@Controller
@RequestMapping("/s/loginInfo")
public class LoginLogController {

	@Autowired
	private LoginforInfoService loginLogService;
	
	@RequestMapping("showList")
	@SecurityChecker("user:loginInfo:search")
	public String showList(ModelMap model){
		return "user-app/loginLog/list";
	}
	
	@RequestMapping("search")
	@SecurityChecker("user:loginInfo:search")
	@OperLog(functionName="查询" , menuName ="登录日志")
	public @ResponseBody ApiBaseResponse<PageInfo<LoginforInfo>> search(ModelMap model ,LoginLogQuery query, PageInfo<LoginforInfo> page){
		if(page == null){
			page = new PageInfo<LoginforInfo>();
		}
		loginLogService.search(query, page);
		return new ApiBaseResponse<PageInfo<LoginforInfo>>( RetStatusEnum.SUCCESS,Constants.API_RESPONSE_SUCCESS_CODE,
				Constants.API_RESPONSE_SUCCESS_MESSAGE, page);
	}
	
	@SecurityChecker("user:loginInfo:remove")
    @RequestMapping("/remove")
	@OperLog(functionName="删除" , menuName ="登录日志")
    @ResponseBody
    public ApiBaseResponse<Boolean> remove(String ids) {
		loginLogService.deleteByIds(ids);
        return new ApiBaseResponse<Boolean>( RetStatusEnum.SUCCESS,Constants.API_RESPONSE_SUCCESS_CODE,
				Constants.API_RESPONSE_SUCCESS_MESSAGE, true);
    }
	
}
